<?php
include("functions.php");
include("libs/smarty.class.php");

$smarty = new Smarty();

$title = "Nowa oferta praktyki";
$smarty->assign("title",$title);
unset($info);

if(!isset($_SESSION['user_id'])){
    $info = "Tylko zarejestrowani użytkownicy mogą dodawać oferty praktyk.";
    $smarty->assign("info",$info);
}


$technologies = array();
$technologies = getRows("*","technologies");

if($_SESSION['user_type'] == 'user_company'){
    $id = $_SESSION['user_id'];
    $company_persons = array();
    $query_cp = mysql_query("SELECT DISTINCT cp.* FROM company_person cp, user_company c WHERE
                cp.company_id = '$id' ");
    while($row = mysql_fetch_assoc($query_cp)){
        $company_persons[] = $row;
    }
    $smarty->assign("company_persons",$company_persons);
}

$data = array();
if($_POST["send"]){
    foreach($_POST as $key => $value){
        $data[$key] = $value;
    }
    echo addPractices($data);
    $info = "Dodano nową praktykę.";
    
}
$smarty->assign("info",$info);
$smarty->assign("technologies",$technologies);
$smarty->display('new_practice.tpl');
?>